package com.akkainaction.router.pool.router;

import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.routing.RoundRobinPool;
import com.akkainaction.router.pool.actor.TaskActor;

public class MasterRouterActor extends UntypedActor {
    //router就是一个actor
    ActorRef router;

    @Override
    public void preStart() {
        router = getContext().actorOf(new RoundRobinPool(3).props(Props.create(TaskActor.class)), "taskActor");
        System.out.println("router:"+router);
    }

    @Override
    public void onReceive(Object msg) {
        router.tell(msg, getSender());
    }
}
